package pers.yurwisher.rubick.common.security;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import pers.yurwisher.rubick.common.enums.UserClientType;

import java.time.Duration;
import java.util.List;

/**
 * Security 配置
 *
 * @author yq
 */
@Data
@Component
@ConfigurationProperties(prefix = "rubick.token")
public class CustomSecurityProperties {

    /**
     * token 请求头名称
     */
    private String header;

    /**
     * token 令牌类型,即prefix
     */
    private String type = "Bearer";

    /**
     * 不同客户端 token配置
     */
    private List<ClientTokenConfig> clientTokenConfigs;

    @Data
    public static class ClientTokenConfig {

        /**
         * 客户端类型
         */
        private UserClientType type;

        /**
         * 凭证过期时间
         */
        private Duration expireTime;

        /**
         * 刷新凭证过期时间
         */
        private Duration refreshTokenExpireTime;

    }
}
